/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package telas;

import javax.swing.JOptionPane;
import vacina.Vacina;
import vacina.VacinaDAO;

/**
 *
 * @author Max Weber
 */
public class O8TelaCadastrarVacina extends javax.swing.JFrame {

    /**
     * Creates new form TelaCadastrarVacina
     */
    public O8TelaCadastrarVacina() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tfNomeVacina = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jcParticular = new javax.swing.JCheckBox();
        jcPublica = new javax.swing.JCheckBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        btCancelar = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        iconCad = new javax.swing.JLabel();
        btCadastrar = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tfDoencasEvitadas = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        tfObservacoes = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        tfInformacoes = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("SISVATEC - Sistema de Vacinação");
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel2.setBackground(new java.awt.Color(10, 66, 108));
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel3.setBackground(new java.awt.Color(0, 114, 180));
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/vacina.png"))); // NOI18N
        jPanel3.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, 50));

        jLabel1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 36)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Cadastrar Vacina");
        jPanel3.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 20, -1, -1));

        jPanel2.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 520, 63));

        jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 520, 70));

        jLabel3.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel3.setText("Nome da vacina:");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 90, -1, -1));

        tfNomeVacina.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
        jPanel1.add(tfNomeVacina, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 120, 350, -1));

        jLabel5.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel5.setText("Disponibilidade:");
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 180, -1, -1));

        jcParticular.setBackground(new java.awt.Color(255, 255, 255));
        jcParticular.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
        jcParticular.setText("Clínica particular");
        jPanel1.add(jcParticular, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 210, -1, -1));

        jcPublica.setBackground(new java.awt.Color(255, 255, 255));
        jcPublica.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
        jcPublica.setText("Unidade Pública");
        jPanel1.add(jcPublica, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, -1, -1));

        jLabel6.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel6.setText("Doenças evitadas:");
        jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 180, -1, -1));

        jLabel7.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel7.setText("Observações:");
        jPanel1.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 300, -1, -1));

        jLabel8.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel8.setText("Informações:");
        jPanel1.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 300, -1, -1));

        jPanel8.setBackground(new java.awt.Color(10, 66, 108));
        jPanel8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel8MouseClicked(evt);
            }
        });
        jPanel8.setLayout(new java.awt.GridBagLayout());

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Delete-32.png"))); // NOI18N
        jLabel9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel9MouseClicked(evt);
            }
        });
        jPanel8.add(jLabel9, new java.awt.GridBagConstraints());

        btCancelar.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N
        btCancelar.setForeground(new java.awt.Color(255, 255, 255));
        btCancelar.setText("  Cancelar");
        btCancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btCancelarMouseClicked(evt);
            }
        });
        jPanel8.add(btCancelar, new java.awt.GridBagConstraints());

        jPanel1.add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 430, 130, 30));

        jPanel7.setBackground(new java.awt.Color(10, 66, 108));
        jPanel7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel7MouseClicked(evt);
            }
        });
        jPanel7.setLayout(new java.awt.GridBagLayout());

        iconCad.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Check-32.png"))); // NOI18N
        iconCad.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                iconCadMouseClicked(evt);
            }
        });
        jPanel7.add(iconCad, new java.awt.GridBagConstraints());

        btCadastrar.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N
        btCadastrar.setForeground(new java.awt.Color(255, 255, 255));
        btCadastrar.setText("  Cadastrar");
        btCadastrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btCadastrarMouseClicked(evt);
            }
        });
        jPanel7.add(btCadastrar, new java.awt.GridBagConstraints());

        jPanel1.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 430, 130, 30));

        tfDoencasEvitadas.setColumns(20);
        tfDoencasEvitadas.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
        tfDoencasEvitadas.setLineWrap(true);
        tfDoencasEvitadas.setRows(5);
        jScrollPane1.setViewportView(tfDoencasEvitadas);

        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 210, 220, 70));

        tfObservacoes.setColumns(20);
        tfObservacoes.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
        tfObservacoes.setLineWrap(true);
        tfObservacoes.setRows(5);
        jScrollPane2.setViewportView(tfObservacoes);

        jPanel1.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 330, 220, 70));

        tfInformacoes.setColumns(20);
        tfInformacoes.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
        tfInformacoes.setLineWrap(true);
        tfInformacoes.setRows(5);
        jScrollPane4.setViewportView(tfInformacoes);

        jPanel1.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 330, 220, 70));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 510, 480));

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btCadastrarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btCadastrarMouseClicked
        Cadastrar();
    }//GEN-LAST:event_btCadastrarMouseClicked

    public void Cadastrar(){
        Vacina vacina = new Vacina();
        vacina.setNome_vacina(tfNomeVacina.getText());
        vacina.setDispParticular(jcParticular.isSelected());
        vacina.setDispPublica(jcPublica.isSelected());
        vacina.setDoencas_evitadas(tfDoencasEvitadas.getText());
        vacina.setObservacoes(tfObservacoes.getText());
        vacina.setInformacoes(tfObservacoes.getText());

        VacinaDAO dao = new VacinaDAO();
        dao.adicionar(vacina);
        limparCampos();
        JOptionPane.showMessageDialog(rootPane, "Vacina cadastrada com sucesso!");
    }
    
    private void btCancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btCancelarMouseClicked
        Cancelar();
    }//GEN-LAST:event_btCancelarMouseClicked

    private void jLabel9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel9MouseClicked
        Cancelar();
    }//GEN-LAST:event_jLabel9MouseClicked

    private void jPanel8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel8MouseClicked
        Cancelar();
    }//GEN-LAST:event_jPanel8MouseClicked

    private void iconCadMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_iconCadMouseClicked
        Cadastrar();
    }//GEN-LAST:event_iconCadMouseClicked

    private void jPanel7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel7MouseClicked
        // TODO add your handling code here:
        Cadastrar();
    }//GEN-LAST:event_jPanel7MouseClicked

    public void Cancelar(){
        dispose();
    }
    public void limparCampos(){
    tfNomeVacina.setText("");
    jcParticular.setSelected(false);
    jcPublica.setSelected(false);
    tfDoencasEvitadas.setText("");
    tfObservacoes.setText("");
    tfObservacoes.setText("");
}
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(O8TelaCadastrarVacina.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(O8TelaCadastrarVacina.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(O8TelaCadastrarVacina.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(O8TelaCadastrarVacina.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new O8TelaCadastrarVacina().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel btCadastrar;
    private javax.swing.JLabel btCancelar;
    private javax.swing.JLabel iconCad;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JCheckBox jcParticular;
    private javax.swing.JCheckBox jcPublica;
    private javax.swing.JTextArea tfDoencasEvitadas;
    private javax.swing.JTextArea tfInformacoes;
    private javax.swing.JTextField tfNomeVacina;
    private javax.swing.JTextArea tfObservacoes;
    // End of variables declaration//GEN-END:variables
}
